/*
  * File:		libpbd.h
  * Purpose:	Interface to programmer to build a packet. libpbd is short for
  *			library packet build. Wring this library while reading libnet open
  *			source project code, maining to study from libnet. This library can
  *			offer programmer an convenient way to build any packet using in 
  *			the network as he like. Some packet you can build could be arp, icmp,
  *			ipv4, ipv6 and so on.
  * Author:	yoyo
  * Date:	2011-6-23
  */

#ifndef _LIB_PBD_H
#define _LIB_PBD_H

#include "libpbd_data.h"

/*
  * Called before using libpbd to build packet. 'device' can be assigned device
  * name or give NULL, it finishes necessary environment initialze.
  * @device - device name, such as 'eth0'
  * Return handle of libpbd if success, otherwise return NULL
  */
pbd_handle_t *libpbd_init(char *device);

/*
  * Called when not using libpbd.
  * @ handle - handle of libpbd to destroy
  * Return 1 if success, otherwise return -1
  */
int libpbd_destroy(pbd_handle_t *handle);

/*
  * Organizing build packet into packet format, and get it
  * @handle - handle of libpbd to get packet
  * @size - packet size
  * Return packet content if success, otherwise return NULL
  */
char *libpbd_to_packet(pbd_handle_t *handle, int *size);

/*
  * Show version of libpbd library
  */
void pbd_show_version();

/* -------------------- Packet Building ------------------------- */
// Layer Two
int pbd_build_ether(pbd_handle_t *handle, uint8 *src, uint8 *dst, uint16 type);
int pbd_auto_build_ether(pbd_handle_t *handle, uint8 *dst, uint16 type);

// Layer Two Point Five
int pbd_build_arp(pbd_handle_t *handle, uint16 hd, uint16 pt, uint8 hdl, uint8 ptl, uint16 op, uint8 *sha, uint8 *sip, uint8 *tha, uint8 *tip);
int pbd_auto_build_arp(pbd_handle_t *handle, uint16 op, uint8 *sha, uint8 *sip, uint8 *tha, uint8 *tip);

// Layer Three

// Layer Three Point Five

// Layer Four

// Layer Five

#endif
  
